<?php

/**
 * This is the model class for table "{{mobile_article}}".
 *
 * The followings are the available columns in table '{{mobile_article}}':
 * @property integer $moea_id
 * @property string $moea_title
 * @property string $moea_desc
 * @property string $moea_tag
 * @property string $moea_content
 */
class mobile_article extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return mobile_article the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mobile_article}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('moea_title, moea_content', 'required'),
			array('moea_title, moea_tag', 'length', 'max'=>100),
			array('moea_desc', 'length', 'max'=>500),
			array('moea_time', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('moea_id, moea_title, moea_desc, moea_tag, moea_content', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'moea_id' => '文章编号',
			'moea_title' => '文章标题',
			'moea_desc' => '文章再要',
			'moea_tag' => '文章tag',
			'moea_content' => '文章内容',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('moea_id',$this->moea_id);

		$criteria->compare('moea_title',$this->moea_title,true);

		$criteria->compare('moea_desc',$this->moea_desc,true);

		$criteria->compare('moea_tag',$this->moea_tag,true);

		$criteria->compare('moea_content',$this->moea_content,true);

		return new CActiveDataProvider('mobile_article', array(
			'criteria'=>$criteria,
		));
	}
}